package silvercrux.runtime;

import java.time.temporal.ValueRange;
import java.util.ArrayList;

/**
 * Created by SilverCrux on 2016/12/8.
 */
public class Array {
    public String type;
    public int size;
    public Var[] array = null;

    public Array(SCCTYPE scctype,int size)
    {
        this.size = size;
        DefType(scctype);
    }

    public Array(SCCTYPE scctype, int size, ArrayList<Object> vals)
    {
        this.size = size;
        DefType(scctype);
        for(int i=0;i<vals.size();i++)
        {
            array[i].value = vals.get(i);
        }
    }

    private void DefType(SCCTYPE scctype)
    {
        switch (scctype)
        {
            case INT:
                type = "Integer";
                InitArray(scctype,size);
                break;
            case DOUBLE:
                type = "Double";
                InitArray(scctype,size);
                break;
            case FLOAT:
                type = "Float";
                InitArray(scctype,size);
                break;
            default:
        }
    }

    private void InitArray(SCCTYPE scctype,int size)
    {
        array = new Var[size];
        for(int i=0;i<size;i++)
        {
            array[i] = new Var(scctype,0);
        }
    }
}
